
             
/**
 * Copyright (c) 2012-2013 JLLT Corp. 2012-2013,All Rights Reserved.
 * This software is published under the 金麟龙腾商贸有限公司.
 * License version 1.0, a copy of which has been included with this
 * distribution in the LICENSE.txt file.
 *
 * @File name:  UpdateTStoresAction.java   修改【门店信息:T_STORES】
 * @Create on:  2012-08-08 00:56:567
 * @Author   :  陈伟
 *
 * @ChangeList
 * ---------------------------------------------------
 * Date         Editor              ChangeReasons
 *
 */
           
        

package com.boho.ecp.deposit.store.action;

            
import java.sql.Connection;
import java.util.Date;

import cn.boho.framework.actions.ActionImp;
import cn.boho.framework.context.ActionContext;
import cn.boho.framework.exception.UserOperationException;
import cn.boho.framework.po.POUtils;
import cn.boho.framework.service.MessageService;

import com.boho.ecp.po.TStoresPO;
import com.boho.ecp.util.MatchUtils;
            
        
public class UpdateTStoresAction extends ActionImp {
	private TStoresPO conditionTStoresPO = new TStoresPO();
	private TStoresPO valueTStoresPO = new TStoresPO();
	private Date date = new Date();
	private Connection con=null;
	private Integer storeNo;
	private String storeName;
	private String address;
	private String personnalNo;
	private String updateBy;
	@Override
	protected void doException(ActionContext atx, Exception ex) {
		if (!(ex instanceof UserOperationException)) {
			atx.setErrorContext("BOHO_COMMON_1002", MessageService.getMessage("BOHO_COMMON_1002"),"【门店信息】" ,ex);
		}
	}
	@Override
	protected int performExecute(ActionContext atx) throws Exception {
		if(MatchUtils.isEmpty(storeNo)){
			valueTStoresPO.setStoresName(storeName);
			valueTStoresPO.setAddress(address);
			valueTStoresPO.setPersonnalNo(personnalNo);
			valueTStoresPO.setCreateBy(updateBy);
			valueTStoresPO.setCreateDate(date);
			POUtils.insert(con, valueTStoresPO, false);
		}
		else{
			conditionTStoresPO.setStoresNo(storeNo);
			valueTStoresPO.setStoresName(storeName);
			valueTStoresPO.setAddress(address);
			valueTStoresPO.setPersonnalNo(personnalNo);
			valueTStoresPO.setUpdateBy(updateBy);
			valueTStoresPO.setUpdateDate(date);
			POUtils.update(con, conditionTStoresPO, valueTStoresPO, false);
		}
		
		return 1;
	}
	@Override
	protected int verifyParameters(ActionContext atx) throws Exception {
		con = atx.getConection();
		updateBy = atx.getStringValue("SESSION_USER_NO");
		storeNo = atx.getIntegerValue("STORES_NO",-1);
		storeName = atx.getStringValue("STORES_NAME");
		address = atx.getStringValue("ADDRESS");
		personnalNo = atx.getStringValue("PERSONNAL_NO");
		return 1;
	}
}
